from django.urls import re_path
from django.urls import path


from api.views import ProductViewSet, OrderViewSet

from rest_framework.routers import DefaultRouter
from api.views.InventoryViewSet import ReceiptOrderDetailViewSet, ReceiptOrderViewSet, ItemSkuViewSet, BoardListViewSet, ReceiptOrderListViewSet

router = DefaultRouter()

# router.register(r'wms/formula', ProductViewSet.ProductFormulaViewSet)

urlpatterns = [
    re_path(r'wms/product/$', ProductViewSet.ProductViewSet.as_view({'post': 'create'})),
    re_path(r'wms/product/list/$', ProductViewSet.ProductListViewSet.as_view({'get': 'list'})),
    re_path(r'wms/product/(?P<pk>\d+)/$', ProductViewSet.ProductViewSet.as_view({'get': 'retrieve', 'delete': 'destroy', 'patch': 'update'})),
    re_path(r'wms/product/formula/$', ProductViewSet.ProductFormulaViewSet.as_view({'get': 'list', 'post': 'create', 'patch': 'update'})),

    re_path(r'wms/order/$', OrderViewSet.OrderViewSetList.as_view({'get': 'list', 'post': 'create'})),
    re_path(r'wms/order/detail/$', OrderViewSet.OrderDetailViewSet.as_view({'get': 'list'})),
    re_path(r'wms/order/create/$', OrderViewSet.OrderViewSet.as_view({'get': 'retrieve', 'post': 'create', 'patch': 'update'})),
    re_path(r'wms/order/set/(?P<pk>\d+)/$', OrderViewSet.OrderViewSet.as_view({'get': 'retrieve', 'post': 'create', 'patch': 'update', 'delete': 'destroy'})),

    # 库存记录
    re_path(r'wms/Inventory/boardList/$', BoardListViewSet.as_view({'get': 'list', 'patch': 'update'})),
    # 入库单详情
    re_path(r'wms/Inventory/receiptOrderDetail/$', ReceiptOrderDetailViewSet.as_view({'get': 'list'})),
    re_path(r'wms/Inventory/receiptOrderDetail/(?P<pk>\d+)/$', ReceiptOrderDetailViewSet.as_view({'patch': 'update','delete': 'destroy'})),
    # 入库单
    re_path(r'wms/Inventory/receiptOrder/$', ReceiptOrderListViewSet.as_view({'get': 'list', 'post': 'create'})),
    re_path(r'wms/Inventory/receiptOrder/(?P<pk>\d+)/$', ReceiptOrderViewSet.as_view({'get': 'retrieve','patch': 'update', 'delete': 'destroy'})),
    # 查询itemsku详情
    re_path(r'wms/Inventory/itemSku/', ItemSkuViewSet.as_view({'get': 'list', 'post': 'create'})),

    # re_path(r'^getRouter', UserInfoViewSet.UserMenuRouterViewSet.as_view({'get': 'list'}))
]
